<?php

class ParamUtils {
	public static function get($key) {
		$result = isset ( $_GET ["$key"] ) ? $_GET ["$key"] : null;
		if ($result == null) {
			$result = isset ( $_POST ["$key"] ) ? $_POST ["$key"] : null;
		}
		return $result;
	}
	
	public static function getString($key) {
		$result = self::get ( $key );
		
		if (is_array ( $result )) {
			$resultAsStr = "";
			for($i = 0; $i < sizeof ( $result ) - 1; $i ++) {
				$resultAsStr .= $result [$i] . ", ";
			}
			$resultAsStr .= $result [sizeof ( $result ) - 1];
			$result = $resultAsStr;
		}
		return $result == null ? "" : $result;
	}
	
	public static function getBoolean($key, $value = null) {
		
		$result = self::get ( $key );
		if ($result != null && $value != null) {
			$thisSame = false;
			if (is_array ( $result )) {
				foreach ( $result as $ele ) {
					if ($ele == $value) {
						$thisSame = true;
						break;
					}
				}
			} else {
				$thisSame = $result == $value ? true : false;
			}
			$result = $thisSame;
		}
		return $result != null ? true : false;
	}
}

?>